package com.openlab.callsystem.controller;

import com.openlab.callsystem.entity.Log;

import com.openlab.callsystem.service.LogService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

@RestController
@RequestMapping("/log")
public class LogController {
    @Autowired
    LogService service;
    @GetMapping("/mainindex")
    public String mainindex(Model model){
        Map<String, Integer> indexData = service.getIndexData();
        for(String key:indexData.keySet()){
            model.addAttribute(key,indexData.get(key));
        }
        return "main-index";
    }
    @RequestMapping("/query")
    public List<Log> query(){
        return service.queryAll();
    }
    @RequestMapping("/getChartsData")
    public Map<String, Map<String, List>> queryByDay(){

        return service.getChartsData();
    }
}
